#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

// https://leetcode.cn/problems/WGki4K/?envType=problem-list-v2&envId=G25w0aD1

class Solution1 {
public:
    int singleNumber(vector<int>& nums) {
        unordered_map<int, int> numFreq;
        for (int curNum : nums)
        {
            numFreq[curNum]++;
        }
        int ans = 0;
        for (auto &[key, value] : numFreq)
        {
            if(value == 1){
                ans = key;
            }
        }
        return ans;
    }
};

class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int a = 0, b = 0;
        for(int x : nums){
            int temp = a;
            a = (a ^ x) & (a | b);
            b = (b ^ x) & ~temp;
        }
        return b;
    }
};

int main()
{
    return 0;
}